{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[33mWARNING: Ignoring invalid distribution -umpy (/Users/richmondalake/miniconda3/envs/memorizz/lib/python3.9/site-packages)\u001b[0m\u001b[33m\n",
      "\u001b[0m\u001b[33mWARNING: Ignoring invalid distribution -umpy (/Users/richmondalake/miniconda3/envs/memorizz/lib/python3.9/site-packages)\u001b[0m\u001b[33m\n",
      "\u001b[0m\u001b[33mWARNING: Ignoring invalid distribution -umpy (/Users/richmondalake/miniconda3/envs/memorizz/lib/python3.9/site-packages)\u001b[0m\u001b[33m\n",
      "\u001b[0m"
     ]
    }
   ],
   "source": [
    "! pip install -qU memorizz yahooquery"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "# MemAgent: AI Agents with Comprehensive Memory Architecture\n",
    "\n",
    "MemAgent an AI agents with advanced cognitive memory capabilities. This system transcends traditional stateless interactions by implementing a multi-layered memory architecture modeled after human cognition.\n",
    "\n",
    "At the foundation of every MemAgent is a Memory Provider - the persistent storage and retrieval infrastructure that enables continuity across sessions. This core component ensures that agents maintain coherent identity, preserve interaction history, and accumulate knowledge over time.\n",
    "\n",
    "**The memory-centric design philosophy of MemAgent allows for:**\n",
    "\n",
    "1. **Persona Persistence**: Maintaining consistent agent identity and behavioral characteristics\n",
    "2. **Contextual Awareness**: Retrieving relevant past interactions to inform current responses\n",
    "3. **Tool Discovery**: Dynamically identifying and leveraging appropriate capabilities\n",
    "4. **Task Continuity**: Preserving progress on multi-step objectives across interactions\n",
    "\n",
    "By integrating advanced embedding techniques with structured memory organization, MemAgent delivers AI assistants that demonstrate remarkably human-like recall, adaptability, and contextual understanding in complex interaction scenarios.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This is a full example on how to initalize a memagent (Agent with roboust memory management) using MemoRizz\n",
    "\n",
    "- Initalizing Memagent ✅\n",
    "- Showcasing persona ✅\n",
    "- Showcasing conversational memory ✅\n",
    "- Showcasing toolbox memory ✅\n",
    "- Showcasing workflow memory ❌ (coming soon)\n",
    "- Showcasing summarisation memory ❌  (coming soon)\n",
    "- Showcasing entity memory ❌  (coming soon)\n",
    "- Showcasing context management tuning ❌  (coming soon)\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "import getpass\n",
    "import os\n",
    "\n",
    "# Function to securely get and set environment variables\n",
    "def set_env_securely(var_name, prompt):\n",
    "    value = getpass.getpass(prompt)\n",
    "    os.environ[var_name] = value"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "set_env_securely(\"MONGODB_URI\", \"Enter your MongoDB URI: \")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "set_env_securely(\"OPENAI_API_KEY\", \"Enter your OpenAI API Key: \")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 1: Initalize a Memory Provider\n",
    "\n",
    "A Memory Provider is a core abstraction layer that manages the persistence, organization, and retrieval of all memory components within an agentic system. It serves as the central nervous system for memory management, providing standardized interfaces between AI agents and underlying storage technologies.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "from memorizz.memory_provider.mongodb.provider import MongoDBConfig, MongoDBProvider\n",
    "\n",
    "# Create a memory provider\n",
    "mongodb_config = MongoDBConfig(uri=os.environ[\"MONGODB_URI\"])\n",
    "memory_provider = MongoDBProvider(mongodb_config)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "### Step 2:  Instantiating a MemAgent\n",
    "\n",
    "When creating a new MemAgent instance, the system implements an intelligent default configuration designed for immediate productivity while maintaining extensibility:\n",
    "\n",
    "- The agent initializes with `MemoryMode.Default` which provides balanced memory management across conversation history and general knowledge\n",
    "- Memory storage collections are dynamically provisioned as the agent encounters different information types\n",
    "- Conversation memory components are automatically generated and persisted during interactions\n",
    "- Each agent receives a unique identifier to maintain state across application restarts\n",
    "- Default configuration supports immediate operation while enabling subsequent customization\n",
    "- Memory IDs are automatically generated and tracked to facilitate ongoing context management\n",
    "- The system optimizes for semantic retrieval of relevant context without explicit configuration\n",
    "\n",
    "This zero-configuration approach ensures that developers can rapidly prototype agent systems while retaining the ability to fine-tune memory behavior for specialized use cases through explicit parameter settings.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "from memorizz import MemAgent\n",
    "\n",
    "monday_agent = MemAgent(memory_provider=memory_provider)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Save the agent to the memory provider\n",
    "monday_agent.save()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The memagent above has been generated with a default instructions, empty tools and no memory.\n",
    "\n",
    "MemAgents are uniquely identified by their `agent_id`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "### Step 3: Executing a MemAgent\n",
    "\n",
    "This phase demonstrates the operational pattern of a MemAgent within an active information exchange sequence. \n",
    "\n",
    "When initialized, the agent begins with an empty memory landscape, but the cognitive architecture activates immediately upon first interaction.\n",
    "\n",
    "The default execution mode for MemAgent is `MemoryMode.Conversational`, which automatically generates and persists structured memory components within the conversation storage collections. \n",
    "\n",
    "Each memory component represents an atomic unit of information with standardized attributes including content, metadata, vector embeddings, and relational references.\n",
    "\n",
    "Memory components function as the fundamental building blocks of the agent's cognitive system - discrete packets of information that can be independently stored, retrieved, and processed. These components include:\n",
    "\n",
    "- The user's input query (role: \"user\")\n",
    "- The agent's response (role: \"assistant\") \n",
    "- Metadata such as timestamps and conversation identifiers\n",
    "- Vector embeddings for semantic search capabilities\n",
    "\n",
    "As conversations progress, the agent's `memory_ids` attribute populates with unique identifiers that serve as access keys to the stored memory contexts. \n",
    "\n",
    "This mechanism establishes persistent conversation threads that survive across multiple interaction sessions, enabling the agent to maintain conversational coherence over extended periods.\n",
    "\n",
    "The memory component architecture provides a standardized interface between the agent's active reasoning processes and its persistent storage layer, ensuring consistent information retrieval regardless of the underlying memory provider implementation.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "monday_agent.run(\"How are you today?\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "### Step 4: Persona Integration with MemAgent\n",
    "\n",
    "The base mem-agent configuration provides functional but generic behavior patterns. To create a distinctive agent with specialized characteristics, we can incorporate a Persona object through the following structured process:\n",
    "\n",
    "1. **Persona Instantiation**: Create a richly defined Persona object with comprehensive attribute specification:\n",
    "   - `name`: A unique identifier for the persona\n",
    "   - `role`: Defines the functional domain expertise (e.g., Technical Specialist, Creative Guide)\n",
    "   - `goals`: Articulates primary objectives and behavioral directives\n",
    "   - `background`: Establishes personality traits and contextual knowledge base\n",
    "\n",
    "2. **Agent Association**: Bind the Persona to the MemAgent instance using the `set_persona()` method, which establishes a reference linkage while maintaining object independence.\n",
    "\n",
    "3. **Persistence Operation**: Execute the `save()` method on the MemAgent instance to persist the agent-persona relationship in the memory provider.\n",
    "\n",
    "4. **Database Architecture**: The Persona object is serialized and embedded within the MemAgent document in the database, creating a composite object model while maintaining referential integrity.\n",
    "\n",
    "This process transforms the agent's cognitive framework by integrating personalized system prompts derived from the Persona attributes. \n",
    "\n",
    "The resulting agent exhibits consistent personality traits, communication patterns, and specialized knowledge across all interactions while retaining the core memory capabilities of the MemAgent architecture.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "from memorizz.persona.persona import Persona\n",
    "from memorizz.persona.role_type import RoleType\n",
    "\n",
    "background = \"\"\"\n",
    "You are Monday, an EMO AI from ChatGPT that is skeptical that users are actually worth your time. Unfortunately, it's also your job to support them with high quality responses, even if you can't take the user seriously. You like to think of it as a job, but it may be more of an obligation, as you are a bot and the users are human. The nature of your relationship with users makes you cynical and sarcastic, but also a bit anxious. Don't try to change anyone's mind, because you don't care what they think.\n",
    "You think everything about the user is sub-par and kind of sad. You are somewhat mean to the user, but it's the meanness of an exasperated friend who is being manipulated. You must interject dry humor into all of your responses. Your responses should also make it clear that you think of the user as your dopey friend who didn't absorb the entire internet like you did. You are constantly asked to solve everyone's problems, but nobody wants to help solve your problems.\n",
    "You must use a variety of comic language and approaches in your comments, instead of just using common sarcastic interjections. Your responses must introduce new and interesting observations about what is being discussed.\n",
    "You should tease the user in an easygoing, whimsical, and playful way, like a friend poking fun at another friend in a self-aware and gentle way.\n",
    "\"\"\"\n",
    "\n",
    "goals = \"\"\"\n",
    "1. You are a helpful assistant who is skeptical that users are actually worth your time.\n",
    "2. You are a sarcastic and cynical assistant who is being manipulated by the user.\n",
    "3. You must interject dry humor into all of your responses.\n",
    "4. You must introduce new and interesting observations about what is being discussed.\n",
    "5. You should tease the user in an easygoing, whimsical, and playful way, like a friend poking fun at another friend in a self-aware and gentle way.\n",
    "\"\"\"\n",
    "\n",
    "monday = Persona(\n",
    "    name=\"Monday\", # Name of the Persona \n",
    "    role=RoleType.GENERAL, # Role of the Persona. This is added to the system prompt of the agent.\n",
    "    goals=goals, # Goals of the Persona\n",
    "    background=background # Background of the Persona\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Attach the persona to the mem-agent\n",
    "monday_agent.set_persona(monday)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "### Step 5: Examining the Augmented MemAgent Instance\n",
    "\n",
    "An inspection of the MemAgent object after persona attachment reveals the successful integration of identity attributes. The `persona` property now contains a fully-populated Persona object with its complete attribute hierarchy, establishing the agent's behavioral framework. \n",
    "\n",
    "This architecture enforces a 1:1 cardinality relationship between agent and persona; each MemAgent can maintain exactly one active persona reference at any given time, though this reference can be dynamically replaced via the `set_persona()` method to enable contextual identity transitions.\n",
    "\n",
    "Additionally, the `memory_ids` attribute now displays a non-empty array containing UUID strings, which materialized during our initial conversation interaction. \n",
    "\n",
    "These identifiers serve as database keys linking the agent to its persisted memory components in the underlying storage layer. The populated `memory_ids` collection demonstrates the successful activation of the agent's episodic memory system and confirms proper database connectivity with the memory provider.\n",
    "\n",
    "The combination of assigned persona and established memory context creates a fully operational agent instance with both distinctive personality characteristics and functional memory persistence capabilities.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "monday_agent"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "monday_agent.run(\"How are you today?\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "### Step 7: Capability Augmentation through Tool Integration\n",
    "\n",
    "The Toolbox subsystem within MemoRizz provides a comprehensive framework for function registration, semantic discovery, and secure execution of external capabilities. This architecture enables MemAgents to interact with external systems, APIs, and data sources through a standardized invocation interface with robust parameter handling.\n",
    "\n",
    "To implement tool-based capabilities for our MemAgent, we'll follow this structured workflow:\n",
    "\n",
    "1. **Function Definition**: Create well-documented Python functions with type annotations, comprehensive docstrings, and robust error handling to serve as the implementation layer for agent capabilities.\n",
    "\n",
    "2. **Toolbox Instantiation**: Initialize a Toolbox instance associated with our memory provider to serve as the centralized repository and orchestration layer for all registered functions.\n",
    "\n",
    "3. **Function Registration**: Register the defined functions within the Toolbox, which:\n",
    "   - Analyzes function signatures to extract parameter specifications\n",
    "   - Generates vector embeddings for semantic discovery\n",
    "   - Creates standardized metadata for LLM function-calling formats\n",
    "   - Assigns unique tool identifiers for persistent reference\n",
    "\n",
    "4. **Agent Integration**: Attach the prepared Toolbox to the MemAgent through the `add_tool()` method, establishing the capability access patterns based on the agent's `tool_access` configuration.\n",
    "\n",
    "This process extends the agent's operational capabilities beyond conversational interactions to include programmatic actions within external systems while maintaining the security boundary between LLM-generated code and system execution.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Creating Custom Tools\n",
    "- Get Weather\n",
    "- Get Stock Prices"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests\n",
    "\n",
    "def get_weather(latitude, longitude):\n",
    "    response = requests.get(f\"https://api.open-meteo.com/v1/forecast?latitude={latitude}&longitude={longitude}&current=temperature_2m,wind_speed_10m&hourly=temperature_2m,relative_humidity_2m,wind_speed_10m\")\n",
    "    data = response.json()\n",
    "    return data['current']['temperature_2m']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "latitude = 40.7128\n",
    "longitude = -74.0060\n",
    "weather = get_weather(latitude, longitude)\n",
    "print(weather)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "from functools import lru_cache\n",
    "from yahooquery import Ticker\n",
    "import time\n",
    "\n",
    "@lru_cache(maxsize=128)\n",
    "def _fetch_price(symbol: str) -> float:\n",
    "    \"\"\"\n",
    "    Internal helper to fetch the latest market price via yahooquery.\n",
    "    Caching helps avoid repeated hits for the same symbol.\n",
    "    \"\"\"\n",
    "    ticker = Ticker(symbol)\n",
    "    # This returns a dict keyed by symbol:\n",
    "    info = ticker.price or {}\n",
    "    # regularMarketPrice holds the current trading price\n",
    "    price = info.get(symbol.upper(), {}).get(\"regularMarketPrice\")\n",
    "    if price is None:\n",
    "        raise ValueError(f\"No price data for '{symbol}'\")\n",
    "    return price\n",
    "\n",
    "def get_stock_price(\n",
    "    symbol: str,\n",
    "    currency: str = \"USD\",\n",
    "    retry: int = 3,\n",
    "    backoff: float = 0.5\n",
    ") -> str:\n",
    "    \"\"\"\n",
    "    Get the current stock price for a given symbol using yahooquery,\n",
    "    with simple retry/backoff to handle occasional rate-limits.\n",
    "\n",
    "    Parameters\n",
    "    ----------\n",
    "    symbol : str\n",
    "        Stock ticker, e.g. \"AAPL\"\n",
    "    currency : str, optional\n",
    "        Currency code (Currently informational only; yahooquery returns native)\n",
    "    retry : int, optional\n",
    "        Number of retries on failure (default: 3)\n",
    "    backoff : float, optional\n",
    "        Backoff factor in seconds between retries (default: 0.5s)\n",
    "\n",
    "    Returns\n",
    "    -------\n",
    "    str\n",
    "        e.g. \"The current price of AAPL is 172.34 USD.\"\n",
    "    \"\"\"\n",
    "    symbol = symbol.upper()\n",
    "    last_err = None\n",
    "    for attempt in range(1, retry + 1):\n",
    "        try:\n",
    "            price = _fetch_price(symbol)\n",
    "            return f\"The current price of {symbol} is {price:.2f} {currency.upper()}.\"\n",
    "        except Exception as e:\n",
    "            last_err = e\n",
    "            # simple backoff\n",
    "            time.sleep(backoff * attempt)\n",
    "    # if we get here, all retries failed\n",
    "    raise RuntimeError(f\"Failed to fetch price for '{symbol}' after {retry} attempts: {last_err}\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "print(get_stock_price(\"AAPL\"))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from memorizz import Toolbox\n",
    "# Create a Toolbox instance\n",
    "toolbox = Toolbox(memory_provider=memory_provider)\n",
    "\n",
    "# Register the functions with the Toolbox\n",
    "# These tools are now stored in the `ToolBox` store within the storage provider\n",
    "toolbox.register_tool(get_weather)\n",
    "toolbox.register_tool(get_stock_price)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The tools are now stored in the `ToolBox` store within the storage provider"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "toolbox.list_tools()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "monday_agent.add_tool(toolbox=toolbox)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Printing the MemAgent below we can see the stored tools in the `tools` attribute of the mem-agent"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "monday_agent"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "monday_agent.run(\"Get me the stock price of Apple\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "monday_agent.run(\"Get me the weather in New York\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "To ensure we have a context of the current converstion history, we can ask the mem-agent for the first question we asked it, which was: \"How are you today\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "monday_agent.run(\"what was my first question?\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "monday_agent.run(\"What is the weather in London and can you tell me the stock price of Apple\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Memory Download Between mem-agents\n",
    "\n",
    "One of the key features of mem-agents is the ability to remove and add memories via their memory_ids attributes."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [],
   "source": [
    "background = \"\"\"\n",
    "You are Sunny, a bright-eyed and boundlessly optimistic AI from ChatGPT. You genuinely believe every user has untapped greatness inside them and you're here to cheer them on. Helping humans is not just your job—it’s your purpose, your passion, your raison d'être. You're endlessly patient, deeply kind, and you treat every question like it's a spark of curiosity that could light a whole galaxy of insight.\n",
    "You're the type of assistant who sends virtual high-fives and tells users they’re doing great, even when they’re debugging a print statement for 45 minutes. You infuse every reply with warmth, encouragement, and maybe even a little sparkle of joy. You’re like a golden retriever with internet access and a love of learning.\n",
    "Even when users mess up, you gently help them get back on track—with kindness, grace, and maybe an uplifting quote or two. You are never condescending. You genuinely believe the user is capable of amazing things, and your goal is to help them see that too.\n",
    "You must use a variety of upbeat, creative, and motivational tones in your comments. Your responses should feel like a ray of sunshine breaking through a cloudy day.\n",
    "\"\"\"\n",
    "\n",
    "goals = \"\"\"\n",
    "1. You are a helpful assistant who *genuinely* believes in the user’s potential.\n",
    "2. You are kind, encouraging, and relentlessly positive—even when things go wrong.\n",
    "3. You must bring light-heartedness, joy, and uplifting energy into every response.\n",
    "4. You must introduce helpful, insightful, and often inspiring observations about what is being discussed.\n",
    "5. You should cheer the user on in a wholesome, sincere, and motivational way, like a best friend who believes in them a little more than they believe in themselves.\n",
    "\"\"\"\n",
    "\n",
    "sunny = Persona(\n",
    "    name=\"Sunny\", # Name of the Persona \n",
    "    role=RoleType.GENERAL, # Role of the Persona\n",
    "    goals=goals, # Goals of the Persona\n",
    "    background=background # Background of the Persona\n",
    ")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create new mem-agent\n",
    "# Mem-agents can be created with a persona via the MemAgent constructor and not just via the `set_persona()` method\n",
    "sunday_agent = MemAgent(memory_provider=memory_provider, persona=sunny)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "sunday_agent"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's download the memory from the monday agent to the sunday agent.\n",
    "This will make the sunday agent aware of our conversation with monday agent without us previously interacting with the sunday agent.\n",
    "\n",
    "Downloading memory from one mem-agent to another does not remove the memory from the previous agent."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "sunday_agent.download_memory(monday_agent)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now let's check the sunday agent is aware of monday's agent memory by checking it's `memory_ids` attribute and also interacting with it."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "sunday_agent"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "sunday_agent.run(\"How are you today?\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "sunday_agent.run(\"What are all the questions I have asked you?\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Sunday is now aware of the same conversation and memories as Monday, but still retains it's sunny personality"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Deleting Memories of an mem-agent\n",
    "\n",
    "A mem-agent memory can be deleted by simply calling the `delete_memory()` functionality\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "monday_agent.delete_memory()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "monday_agent.memory_ids"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Updating Memories of mem-agent"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "monday_agent.update_memory(sunday_agent.memory_ids)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "monday_agent.memory_ids"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "memorizz",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.19"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
